package com.createdevelopment.house.action;

import java.io.File;
import java.util.List;

import com.createdevelopment.house.entity.Picture;
import com.createdevelopment.house.entity.PublicFacility;
import com.createdevelopment.house.service.picture.PictureService;
import com.createdevelopment.house.service.publicfacility.PublicFacilityService;

public class PublicFacilityAction extends BaseAction {
    private PublicFacilityService publicFacilityService;
    private List<PublicFacility> publicFacilities;
    private PublicFacility publicFacility;
    private File logo;
   	private String logoFileName;
   	private String realPath;
   	private PictureService pictureService;
    
    public String loadManagingPublicFacilities(){
    	publicFacilities=publicFacilityService.obtainALLPublicFacilities();
    	return SUCCESS;
    }
    
    public String loadAddPublicFacility(){
    	return SUCCESS;
    }
    
    public String savePublicFacility(){
    	if(logo!=null){
	    	realPath=this.getRequest().getRealPath("/");
	    	Picture logoPicture=pictureService.savePicture(null, logo, logoFileName, realPath);
	    	publicFacility.setLogo(logoPicture);
    	}
    	publicFacilityService.savePublicFacility(publicFacility);
    	return SUCCESS;
    }

    /*
     * set and get methods starts
     */
	public PublicFacilityService getPublicFacilityService() {
		return publicFacilityService;
	}

	public void setPublicFacilityService(PublicFacilityService publicFacilityService) {
		this.publicFacilityService = publicFacilityService;
	}

	public List<PublicFacility> getPublicFacilities() {
		return publicFacilities;
	}

	public void setPublicFacilities(List<PublicFacility> publicFacilities) {
		this.publicFacilities = publicFacilities;
	}

	public PublicFacility getPublicFacility() {
		return publicFacility;
	}

	public void setPublicFacility(PublicFacility publicFacility) {
		this.publicFacility = publicFacility;
	}

	public File getLogo() {
		return logo;
	}

	public void setLogo(File logo) {
		this.logo = logo;
	}

	public String getLogoFileName() {
		return logoFileName;
	}

	public void setLogoFileName(String logoFileName) {
		this.logoFileName = logoFileName;
	}

	public String getRealPath() {
		return realPath;
	}

	public void setRealPath(String realPath) {
		this.realPath = realPath;
	}

	public PictureService getPictureService() {
		return pictureService;
	}

	public void setPictureService(PictureService pictureService) {
		this.pictureService = pictureService;
	}
    
    
}
